package com.schoolinfo.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AuthorInterceptor extends AbstractInterceptor {
	 
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String actionName = invocation.getInvocationContext().getName();
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpSession session =ServletActionContext.getRequest().getSession();
		String url = request.getRequestURI();
		if(url.contains("userCenter.jsp")||url.contains("update"))
		{
			if(session.getAttribute("user")==null)
			{
				return Action.LOGIN;//"login";	//未登录
			}else
			{
				return invocation.invoke();	//已登录，继续操作
			}
		}else{//需要校验
			return invocation.invoke();	//不需要权限校验
			
		}
		
		//return null;
	}

}
